<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/4
 * Time: 10:06
 */

namespace common\business\company;


use common\business\DbHandler;
use common\models\Company;
use common\result\ActionResult;

class CompanyApiHandler extends DbHandler
{
    /**
     * @param Company $newObj
     * @param Company $oldObj
     * @return ActionResult
     */
    public function updateCompany($newObj, $oldObj = null){
        if (!$oldObj){
            $oldObj = Company::findOne([
                'company_hr_id' => $newObj->company_hr_id,
            ]);
        }
        return $this->update($newObj, $oldObj, [
            'company_name',
            'company_plate',
            'company_mdm_id',
            'company_parent_mdm_id',
            'company_hr_id',
//            'company_finance_id',
//            'company_import_id',
//            'company_market_if',
            'company_abb',
            'company_ct_start_date',
            'company_ct_end_date',
//            'company_most_abb',
//            'company_longitude',
//            'company_latitude',
//            'company_update_reason',
//            'company_memo',
        ]);
    }


    /**
     * @param $obj Company
     * @return ActionResult
     */
    public function createCompany($obj){
        return $this->create($obj);
    }
}